import chalk from 'chalk';


// Creat koa server and listen
export const listen = (app) => {
  const config = global.CONFIG.web;
  // const server = http.createServer(app.callback())
  const server = app.listen(config.port, (err) => {
    if (err) {
      console.error(chalk.yellow(`==> 😭  OMG!!! ${err}`));
    }
    // callback();
    const host = server.address().address;
    const port = server.address().port;
    console.info(chalk.green(`==> 🌎  Listening at http://${host}:${port}`));
  });
  return server;
};

export default listen;
